<?php

class Model_pm extends CI_Model {

    function getAll() {
        $owner = $this->session->userdata('id_user');
        $query = $this->db->query("SELECT * FROM tb_pm WHERE id_user=$owner");
        return $query->result();
    }

    function sendpm() {
        $data = array(
            'id_friend' => $this->input->post('nim'),
            'message' => $this->input->post('message'),
            'id_user' => $this->session->userdata('id_user')
        );

        return $this->db->insert('tb_pm', $data);
    }

}

?>
